<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
	<title>Get rollup job capabilities API | ElasticSearch 7.7 权威指南中文版</title>
	<meta name="keywords" content="ElasticSearch 权威指南中文版, elasticsearch 7, es7, 实时数据分析，实时数据检索" />
    <meta name="description" content="ElasticSearch 权威指南中文版, elasticsearch 7, es7, 实时数据分析，实时数据检索" />
    <!-- Give IE8 a fighting chance -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
	<link rel="stylesheet" type="text/css" href="../static/styles.css" />
	<script>
	var _link = 'rollup-get-rollup-caps.html';
    </script>
</head>
<body>
<div class="main-container">
    <section id="content">
        <div class="content-wrapper">
            <section id="guide" lang="zh_cn">
                <div class="container">
                    <div class="row">
                        <div class="col-xs-12 col-sm-8 col-md-8 guide-section">
                            <div style="color:gray; word-break: break-all; font-size:12px;">原英文版地址: <a href="https://www.elastic.co/guide/en/elasticsearch/reference/7.7/rollup-get-rollup-caps.html" rel="nofollow" target="_blank">https://www.elastic.co/guide/en/elasticsearch/reference/7.7/rollup-get-rollup-caps.html</a>, 原文档版权归 www.elastic.co 所有<br/>本地英文版地址: <a href="../en/rollup-get-rollup-caps.html" rel="nofollow" target="_blank">../en/rollup-get-rollup-caps.html</a></div>
                        <!-- start body -->
                  <div class="page_header">
<strong>重要</strong>: 此版本不会发布额外的bug修复或文档更新。最新信息请参考 <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html" rel="nofollow">当前版本文档</a>。
</div>
<div id="content">
<div class="breadcrumbs">
<span class="breadcrumb-link"><a href="index.html">Elasticsearch Guide [7.7]</a></span>
»
<span class="breadcrumb-link"><a href="rest-apis.html">REST APIs</a></span>
»
<span class="breadcrumb-link"><a href="rollup-apis.html">Rollup APIs</a></span>
»
<span class="breadcrumb-node">Get rollup job capabilities API</span>
</div>
<div class="navheader">
<span class="prev">
<a href="rollup-get-job.html">« Get rollup jobs API</a>
</span>
<span class="next">
<a href="rollup-get-rollup-index-caps.html">Get rollup index capabilities API »</a>
</span>
</div>
<div class="section xpack">
<div class="titlepage"><div><div>
<h2 class="title">
<a id="rollup-get-rollup-caps"></a>Get rollup job capabilities API<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/rollup/apis/rollup-caps.asciidoc">edit</a><a class="xpack_tag" href="https://www.elastic.co/subscriptions"></a>
</h2>
</div></div></div>

<p>Returns the capabilities of any rollup jobs that have been configured for a
specific index or index pattern.</p>
<div class="warning admon">
<div class="icon"></div>
<div class="admon_content">
<p>This functionality is experimental and may be changed or removed completely in a future release. Elastic will take a best effort approach to fix any issues, but experimental features are not subject to the support SLA of official GA features.</p>
</div>
</div>
<div class="section">
<div class="titlepage"><div><div>
<h3 class="title">
<a id="rollup-get-rollup-caps-request"></a>Request<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/rollup/apis/rollup-caps.asciidoc">edit</a>
</h3>
</div></div></div>
<p><code class="literal">GET _rollup/data/&lt;index&gt;</code></p>
</div>

<div class="section">
<div class="titlepage"><div><div>
<h3 class="title">
<a id="rollup-get-rollup-caps-prereqs"></a>Prerequisites<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/rollup/apis/rollup-caps.asciidoc">edit</a>
</h3>
</div></div></div>
<div class="ulist itemizedlist">
<ul class="itemizedlist">
<li class="listitem">
If the Elasticsearch security features are enabled, you must have <code class="literal">monitor</code>,
<code class="literal">monitor_rollup</code>, <code class="literal">manage</code> or <code class="literal">manage_rollup</code> cluster privileges to use this API.
For more information, see <a class="xref" href="security-privileges.html" title="Security privileges">Security privileges</a>.
</li>
</ul>
</div>
</div>

<div class="section">
<div class="titlepage"><div><div>
<h3 class="title">
<a id="rollup-get-rollup-caps-desc"></a>Description<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/rollup/apis/rollup-caps.asciidoc">edit</a>
</h3>
</div></div></div>
<p>This API is useful because a rollup job is often configured to rollup only a
subset of fields from the source index. Furthermore, only certain aggregations
can be configured for various fields, leading to a limited subset of
functionality depending on that configuration.</p>
<p>This API enables you to inspect an index and determine:</p>
<div class="olist orderedlist">
<ol class="orderedlist">
<li class="listitem">
Does this index have associated rollup data somewhere in the cluster?
</li>
<li class="listitem">
If yes to the first question, what fields were rolled up, what aggregations
can be performed, and where does the data live?
</li>
</ol>
</div>
</div>

<div class="section">
<div class="titlepage"><div><div>
<h3 class="title">
<a id="rollup-get-rollup-path-params"></a>Path parameters<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/rollup/apis/rollup-caps.asciidoc">edit</a>
</h3>
</div></div></div>
<div class="variablelist">
<dl class="variablelist">
<dt>
<span class="term">
<code class="literal">&lt;index&gt;</code>
</span>
</dt>
<dd>
(string) Index, indices or index-pattern to return rollup capabilities for.
<code class="literal">_all</code> may be used to fetch rollup capabilities from all jobs.
</dd>
</dl>
</div>
</div>

<div class="section">
<div class="titlepage"><div><div>
<h3 class="title">
<a id="rollup-get-rollup-example"></a>Examples<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/rollup/apis/rollup-caps.asciidoc">edit</a>
</h3>
</div></div></div>
<p>Imagine we have an index named <code class="literal">sensor-1</code> full of raw data.  We know that the
data will grow over time, so there will be a <code class="literal">sensor-2</code>, <code class="literal">sensor-3</code>, etc.  Let’s
create a rollup job that targets the index pattern <code class="literal">sensor-*</code> to accommodate
this future scaling:</p>
<div class="pre_wrapper lang-console">
<pre class="programlisting prettyprint lang-console">PUT _rollup/job/sensor
{
    "index_pattern": "sensor-*",
    "rollup_index": "sensor_rollup",
    "cron": "*/30 * * * * ?",
    "page_size" :1000,
    "groups" : {
      "date_histogram": {
        "field": "timestamp",
        "fixed_interval": "1h",
        "delay": "7d"
      },
      "terms": {
        "fields": ["node"]
      }
    },
    "metrics": [
        {
            "field": "temperature",
            "metrics": ["min", "max", "sum"]
        },
        {
            "field": "voltage",
            "metrics": ["avg"]
        }
    ]
}</pre>
</div>
<div class="console_widget" data-snippet="snippets/1872.console"></div>
<p>We can then retrieve the rollup capabilities of that index pattern (<code class="literal">sensor-*</code>)
via the following command:</p>
<div class="pre_wrapper lang-console">
<pre class="programlisting prettyprint lang-console">GET _rollup/data/sensor-*</pre>
</div>
<div class="console_widget" data-snippet="snippets/1873.console"></div>
<p>Which will yield the following response:</p>
<div class="pre_wrapper lang-console-result">
<pre class="programlisting prettyprint lang-console-result">{
  "sensor-*" : {
    "rollup_jobs" : [
      {
        "job_id" : "sensor",
        "rollup_index" : "sensor_rollup",
        "index_pattern" : "sensor-*",
        "fields" : {
          "node" : [
            {
              "agg" : "terms"
            }
          ],
          "temperature" : [
            {
              "agg" : "min"
            },
            {
              "agg" : "max"
            },
            {
              "agg" : "sum"
            }
          ],
          "timestamp" : [
            {
              "agg" : "date_histogram",
              "time_zone" : "UTC",
              "fixed_interval" : "1h",
              "delay": "7d"
            }
          ],
          "voltage" : [
            {
              "agg" : "avg"
            }
          ]
        }
      }
    ]
  }
}</pre>
</div>
<p>The response that is returned contains information that is similar to the
original rollup configuration, but formatted differently.  First, there are some
house-keeping details: the rollup job ID, the index that holds the rolled data,
and the index pattern that the job was targeting.</p>
<p>Next it shows a list of fields that contain data eligible for rollup searches.
Here we see four fields: <code class="literal">node</code>, <code class="literal">temperature</code>, <code class="literal">timestamp</code> and <code class="literal">voltage</code>. Each
of these fields list the aggregations that are possible. For example, you can
use a min, max or sum aggregation on the <code class="literal">temperature</code> field, but only a
<code class="literal">date_histogram</code> on <code class="literal">timestamp</code>.</p>
<p>Note that the <code class="literal">rollup_jobs</code> element is an array; there can be multiple,
independent jobs configured for a single index or index pattern. Each of these
jobs may have different configurations, so the API returns a list of all the
various configurations available.</p>
<p>We could also retrieve the same information with a request to <code class="literal">_all</code>:</p>
<div class="pre_wrapper lang-console">
<pre class="programlisting prettyprint lang-console">GET _rollup/data/_all</pre>
</div>
<div class="console_widget" data-snippet="snippets/1874.console"></div>
<p>But note that if we use the concrete index name (<code class="literal">sensor-1</code>), we’ll retrieve no
rollup capabilities:</p>
<div class="pre_wrapper lang-console">
<pre class="programlisting prettyprint lang-console">GET _rollup/data/sensor-1</pre>
</div>
<div class="console_widget" data-snippet="snippets/1875.console"></div>
<div class="pre_wrapper lang-console-result">
<pre class="programlisting prettyprint lang-console-result">{

}</pre>
</div>
<p>Why is this?  The original rollup job was configured against a specific index
pattern (<code class="literal">sensor-*</code>) not a concrete index (<code class="literal">sensor-1</code>).  So while the index
belongs to the pattern, the rollup job is only valid across the entirety of
the pattern not just one of it’s containing indices. So for that reason, the
get rollup capabilities API only returns information based on the originally
configured index name or pattern.</p>
</div>

</div>
<div class="navfooter">
<span class="prev">
<a href="rollup-get-job.html">« Get rollup jobs API</a>
</span>
<span class="next">
<a href="rollup-get-rollup-index-caps.html">Get rollup index capabilities API »</a>
</span>
</div>
</div>

                  <!-- end body -->
                        </div>
                        <div class="col-xs-12 col-sm-4 col-md-4" id="right_col">
                        
                        </div>
                    </div>
                </div>
            </section>
        </div>
    </section>
</div>
<script src="../static/cn.js"></script>
</body>
</html>